﻿namespace GreenIsomer.Data.Entities.Ddl {
	using System;
	using System.Xml.Serialization;

	[Serializable, XmlType("GuidColumn", Namespace = Settings.Namespace)]
	public class GuidColumn : Column {

		public GuidColumn() { }

		public override void WriteScript(DdlWriter writer, Value value) {

			if(string.IsNullOrEmpty(value.Text)) {
				writer.WriteNull();
				return;
			}

			try {
				Guid guid = new Guid(value.Text);
				writer.Write(guid);
			} catch(FormatException) {
				writer.WriteNull();
			}
		}

	}

}